<?php

/**
 * 系统后台公用函数库
 */

/**
 * 系统提示信息
 *
 * @param string $msg
 * @param array $links
 * @param int $type
 * @param bool $auto_redirect
 */
function message($msgs, $links = array(), $type = 0, $auto_redirect = true) {
	$msg = A ( 'Index' );
	$msg->message ( $msgs, $links, $type, $auto_redirect );
	exit;
}

/**
 * FCK在线编辑器
 *
 * @param string $inputName
 * @param string $content
 * @param string $toolbar
 * @param string $width
 * @param string $height
 * @return string
 */
function fckeditor($inputName = 'content', $content = '', $toolbar = 'Default', $width = '100%', $height = '320') {
	Vendor('fckeditor.fckeditor');
	$editor = new FCKeditor ($inputName );
	$editor->BasePath = '/'.VENDOR_PATH.'/fckeditor/';
	$editor->ToolbarSet = $toolbar;
	$editor->Width = $width;
	$editor->Height = $height;
	$editor->Value = $content;
	return $editor->CreateHtml ();
}

/**
 * 删除指定目录与目录下的文件
 *
 * @param string $dirname
 * @return bool
 */
function rmdirr($dirname) {
	
	if ( ! file_exists ( $dirname ) ) {return false;}
	
	if ( is_file ( $dirname ) || is_link ( $dirname ) ) {return unlink ( $dirname );}
	
	$dir = dir ( $dirname );
	
	while ( false !== $entry = $dir->read () ) {
		
		if ( $entry == '.' || $entry == '..' ) {
			continue;
		}
		
		rmdirr ( $dirname . DIRECTORY_SEPARATOR . $entry );
	}
	
	$dir->close ();
	
	return rmdir ( $dirname );
}
?>